﻿using System;
using System.Collections.Generic;
using System.Text;
using DASwindles;
using System.Collections;
using OBSwindles;
using NHibernate;

namespace BLSwindles
{
    public class BLLogin : IBLClass
    {
        DAHelper helper = new DAHelper();
        #region IBLClass Members

        public IList getDetails()
        {
            IList list = new List<Login>();

            list = DataFactory.getLoginDetails();
            return list;
        }

        public object getDetails_ByID(int p_ID)
        {
            object objLogin = DataFactory.getLogin_ByID(p_ID);
            return objLogin;
        }

        public void updateDetails(object p_Object)
        {
            using (ISession session = DAHelper.getSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        DataFactory.updateLogin(p_Object);
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }
                }
            }
        }

        public int insertDetails(object p_Object)
        {
            int loginID = 0;
            using (ISession session = DAHelper.getSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        loginID = DataFactory.insertLogin(p_Object);
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }

                }
            }
            return loginID;
        }

        #endregion
    }
}
